<!-- INCLUDE sv_overall_header.html -->


<SCRIPT>
var form_submitted = false;

function validate()
{	
	if( form_submitted == true )
	{
		return false;
  	}
  	
	var corp_id = get_selected_corp_id();
	
	if (corp_id == '')
	{
		// it will be empty if there is only one radio. 
		corp_id = 	document.forms['short_cover_form'].elements['corp_id'].value;
	}

	var number_id = corp_id + "_number";
	
	var	number_to_sell = parseInt(document.forms['short_cover_form'].elements[number_id].value);
	
	var number_id = corp_id + "_SHORT_COVERABLE_NUMBER";
	var	number_sellable = parseInt(document.forms['short_cover_form'].elements[number_id].value);

	if (number_to_sell > number_sellable)
	{
		alert("{L_SV_NOT_ENOUGH_SHARE_SELL}");
		return false;
	}
	
	market_price = document.getElementById('request_price_radio_0').checked;
	//alert(market_price);

	if (market_price)
	{
		document.forms['short_cover_form'].elements['request_price'].value = 0;				
	}
	else
	{
		request_price = parseFloat(document.forms['short_cover_form'].elements['request_price_text'].value);
				
		if (request_price > 0 && request_price < 99999)
		{
			document.forms['short_cover_form'].elements['request_price'].value = request_price;
		}
		else
		{
			alert('{L_SV_REQUEST_PRICE_NOT_OK}');
			return false;
		}
	}
	
	form_submitted = true; 
	
	return true;
}

function get_selected_corp_id()
{
	var	radio_corp_id = document.forms['short_cover_form'].elements['corp_id'];

	for (i = 0; i < radio_corp_id.length; ++i)
	{
		if (radio_corp_id.item(i).checked == true)
			return radio_corp_id.item(i).value;
	}

	return '';
}

function number_change(number)
{
	var postfix		= "_number";
	var number_id	= number.id;
	var to			= number_id.length - postfix.length;	
	var corp_id		= number_id.substring(0, to);

	var	radio_corp_id = document.forms['short_cover_form'].elements['corp_id'];

	for (i = 0; i < radio_corp_id.length; ++i)
	{
		if (radio_corp_id.item(i).value == corp_id)
			radio_corp_id.item(i).checked = true;			
	}
}


function ShowContent(d) 
{
	document.getElementById(d).style.display = "block";
}

function HideContent(d) 
{
	document.getElementById(d).style.display = "none";
}
	
function ShowRequestPriceDiv()
{
	ShowContent('request_price_div');
	HideContent('market_price_div');
	document.getElementById("request_price_radio_1").checked = true;
	document.getElementById("request_price_text").focus();
}
    
function onPriceTextChange()
{
	document.getElementById("request_price_radio_1").checked = true;
}

</SCRIPT>

<!-- IF not S_USER_LOGGED_IN and not S_IS_BOT -->
	<form method="post" action="{S_LOGIN_ACTION}" class="headerspace">
	<h3><a href="{U_LOGIN_LOGOUT}">{L_LOGIN_LOGOUT}</a><!-- IF S_REGISTER_ENABLED -->&nbsp; &bull; &nbsp;<a href="{U_REGISTER}">{L_REGISTER}</a><!-- ENDIF --></h3>
		<fieldset class="quick-login">
			<label for="username">{L_USERNAME}:</label>&nbsp;<input type="text" name="username" id="username" size="10" class="inputbox" title="{L_USERNAME}" />
			<label for="password">{L_PASSWORD}:</label>&nbsp;<input type="password" name="password" id="password" size="10" class="inputbox" title="{L_PASSWORD}" />
			<!-- IF S_AUTOLOGIN_ENABLED -->
				| <label for="autologin">{L_LOG_ME_IN} <input type="checkbox" name="autologin" id="autologin" /></label>
			<!-- ENDIF -->
			<input type="submit" name="login" value="{L_LOGIN}" class="button2" />
			{S_LOGIN_REDIRECT}
		</fieldset>
	</form>
<!-- ENDIF -->


<!-- IF S_SHORT_STOCK_LIST  -->
<div class="panel" > 
	<div class="inner"><span class="corners-top"><span></span></span> 
	<h2>{L_SV_SHORT_COVER}  &nbsp<img title="{L_SV_SHORT_COVER_PAGE_INFO}" src="{T_IMAGES_PATH}icons/smile/info.gif" alt="info" /></h2> 
	</div>
	<form name="short_cover_form" method="post" action="{S_SHORT_COVER_ACTION}" onsubmit="return validate();">
		
	<table border="0" cellpadding="5" cellspacing="5">
		<tr>
			<td title="{L_SV_SHORT_COVER_PAGE_TIP_SELECTION}"><p> </p></td>
			<td title="{L_SV_SHORT_COVER_PAGE_TIP_SELECTION}"><p> </p></td>
			<td title="{L_SV_COMMON_TIP_CORP_ID}"><p>{L_SV_CORP_NAME}</p></td>
			<td title="{L_SV_SHORT_COVER_PAGE_TIP_SHORT_COVERABLE_NUMBER}" align="center"><p>{L_SV_SHORT_COVERABLE_NUMBER}</p></td>
			<td title="{L_SV_SHORT_COVER_PAGE_TIP_SHORT_NUMBER}" align="center"><p>{L_SV_SHORT_NUMBER}</p></td>
			<td title="{L_SV_SHORT_COVER_PAGE_TIP_TO_SHORT_COVER_NUMBER}" align="center"><p>{L_SV_TO_SHORT_COVER_NUMBER}</p></td>
			<td title="{L_SV_SHORT_COVER_PAGE_TIP_COST}" align="center"><p>{L_SV_COST}</p></td>
			<td title="{L_SV_SHORT_COVER_PAGE_TIP_REFERED_PRICE}" align="center"><p>{L_SV_REFERED_PRICE}</p></td>				
			<td title="{L_SV_SHORT_COVER_PAGE_TIP_DEPOSIT}" align="center"><p>{L_SV_DEPOSIT}</p></td>				
			<td title="{L_SV_SHORT_COVER_PAGE_TIP_NOTE}" align="center"><p>{L_SV_NOTE}</p></td>				
		</tr>
		<!-- BEGIN short_stock_list -->
		<tr>
			<!-- IF short_stock_list.CANNOT_SELL  -->
			<td title="{L_SV_SHORT_COVER_PAGE_TIP_SELECTION}"><p> <input type="radio" name="corp_id" value="{short_stock_list.CORP_ID}" disabled="disabled"> </p></td>
			<td title="{L_SV_SHORT_COVER_PAGE_TIP_SELECTION}"><p> <input type="text" name="{short_stock_list.CORP_ID}_number" size="10" value="0" disabled="disabled"> </p></td>
			<!-- ELSE -->
			<td title="{L_SV_SHORT_COVER_PAGE_TIP_SELECTION}"><p> <input type="radio" name="corp_id" value="{short_stock_list.CORP_ID}" checked> </p></td>
			
			
			<td title="{L_SV_SHORT_COVER_PAGE_TIP_SELECTION}"><p>
				<select name="{short_stock_list.CORP_ID}_number" id="{short_stock_list.CORP_ID}_number" class="row2" title="{L_SV_NUMBER}" onchange="number_change(this);">
					<OPTION VALUE="1" SELECTED>1 </OPTION>
					<!-- IF short_stock_list.SHORT_COVERABLE_NUMBER >= 2  --> <OPTION VALUE="2"> 2 </OPTION> <!-- ENDIF -->
					<!-- IF short_stock_list.SHORT_COVERABLE_NUMBER >= 3  --> <OPTION VALUE="3"> 3 </OPTION> <!-- ENDIF -->
					<!-- IF short_stock_list.SHORT_COVERABLE_NUMBER >= 4  --> <OPTION VALUE="4"> 4 </OPTION> <!-- ENDIF -->
					<!-- IF short_stock_list.SHORT_COVERABLE_NUMBER >= 5  --> <OPTION VALUE="5"> 5 </OPTION> <!-- ENDIF -->
					<!-- IF short_stock_list.SHORT_COVERABLE_NUMBER >= 10  --> <OPTION VALUE="10"> 10 </OPTION> <!-- ENDIF -->
					<!-- IF short_stock_list.SHORT_COVERABLE_NUMBER >= 20  --> <OPTION VALUE="20"> 20 </OPTION> <!-- ENDIF -->					
					<!-- IF short_stock_list.SHORT_COVERABLE_NUMBER >= 50  --> <OPTION VALUE="50"> 50 </OPTION> <!-- ENDIF -->					
					<!-- IF short_stock_list.SHORT_COVERABLE_NUMBER >= 100  --> <OPTION VALUE="100"> 100 </OPTION> <!-- ENDIF -->	
					
					<!-- IF short_stock_list.SHORT_COVERABLE_NUMBER > 5 -->
					<!-- IF short_stock_list.SHORT_COVERABLE_NUMBER != 10 -->
					<!-- IF short_stock_list.SHORT_COVERABLE_NUMBER != 20 -->
					<!-- IF short_stock_list.SHORT_COVERABLE_NUMBER != 50 -->
					<!-- IF short_stock_list.SHORT_COVERABLE_NUMBER != 100 -->
					<OPTION VALUE="{short_stock_list.SHORT_COVERABLE_NUMBER}"> {short_stock_list.SHORT_COVERABLE_NUMBER} </OPTION> 
					<!-- ENDIF --> <!-- ENDIF --> <!-- ENDIF --> <!-- ENDIF --> <!-- ENDIF -->				
				</select>
			</p></td>
			<!-- ENDIF -->
			
			
			<td title="{L_SV_COMMON_TIP_CORP_ID}"><p>{short_stock_list.CORP_NAME}({short_stock_list.CORP_ID})</p></td>
			
			<td title="{L_SV_SHORT_COVER_PAGE_TIP_SHORT_COVERABLE_NUMBER}" align="center"><p>{short_stock_list.SHORT_COVERABLE_NUMBER} 
				<input type="hidden" name="{short_stock_list.CORP_ID}_SHORT_COVERABLE_NUMBER" size="10" value="{short_stock_list.SHORT_COVERABLE_NUMBER}">
			</p></td>
			<td title="{L_SV_SHORT_COVER_PAGE_TIP_SHORT_NUMBER}" align="center"><p>{short_stock_list.HOLDING_NUMBER}</p></td>
			<td title="{L_SV_SHORT_COVER_PAGE_TIP_TO_SHORT_COVER_NUMBER}" align="center"><p>{short_stock_list.TO_SHORT_COVER_NUMBER}</p></td>
			<td title="{L_SV_SHORT_COVER_PAGE_TIP_COST}" align="center"><p>{short_stock_list.COST}</p></td>
			<td title="{L_SV_SHORT_COVER_PAGE_TIP_REFERED_PRICE}" align="center"><p>{short_stock_list.REFERED_PRICE}</p></td>	
			<td title="{L_SV_SHORT_COVER_PAGE_TIP_DEPOSIT}" align="center"><p>{short_stock_list.DEPOSIT}</p></td>	
			<td title="{L_SV_SHORT_COVER_PAGE_TIP_NOTE}" align="center"><p>{short_stock_list.NOTE}</p></td>	
			
		</tr>
		<!-- END short_stock_list -->

		<tr> <td><p> </p></td> </tr>
	</table>
	
	
	
	<input type="hidden" name="request_price" id="request_price" value="0">
	
	<div id="market_price_div" style="display:block;">
	<table width="40%">			
		<tr title="{L_SV_REQUEST_PRICE_TIP_NOTE}"> 
			<td ><label ><p>{L_SV_REQUEST_PRICE}:</p></label> </td> 
			<td ><label > <p> {L_SV_MARKET_PRICE}  <a href="javascript:ShowRequestPriceDiv();">
					({L_SV_SPECIFY_PRICE_LINK})
				</a> </p>
			</td> 			
		</tr>		
	</table>    			
	</div>		
	    
	<div id="request_price_div" style="display:none;">
	<table>			
		<tr title="{L_SV_REQUEST_PRICE_TIP_NOTE}"> 
			<td ><label ><p>{L_SV_REQUEST_PRICE}:  </p></label> </td> 
			<td >  <input type="radio" name="request_price_radio" id="request_price_radio_0" value="0" checked> {L_SV_MARKET_PRICE}  </td>
			
		</tr>
		<tr title="{L_SV_REQUEST_PRICE_TIP_NOTE}"> 
			<td >  </td> 
			<td >  <input type="radio" name="request_price_radio" id="request_price_radio_1" value="1" > {L_SV_SPECIFY_PRICE}: 
			<input type="text" name="request_price_text" id="request_price_text" class="inputbox" title="{L_SV_REQUEST_PRICE_TIP_NOTE}" onchange="onPriceTextChange();" />
			 </td>	    
		</tr>
	</table>
	</div>
	
	
	<table width="40%">
		<tr> 
			<td width="40"><label for="note"><p>{L_SV_NOTE}:</label> </p></td> 
			<td  aligh="left"> <input type="textarea" name="note" id="note" size="200" class="inputbox" title="{L_SV_NOTE}" /></p></td>
		</tr>
		<tr>
			<td><p> <input type="submit" name="login" value="{L_SV_SEND}" class="button2" /></p></td>
		</tr>
	</table>
	
	</form>
</div>
<!-- ELSE -->
<div class="panel" > 
	<div class="inner"><span class="corners-top"><span></span></span> 
	<h2>{L_SV_SHORT_COVER}</h2> 
	</div>
	<h3>{L_SV_NO_SHORT_STOCK}</h3>
</div>
<!-- ENDIF -->

<!-- INCLUDE to_short_cover_delegation_list.html -->

<!-- INCLUDE sv_overall_footer.html -->